package com.lrkj.web.controller.system;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.enums.PayType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.system.domain.SysPayConfig;
import com.lrkj.system.service.ISysPayConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 支付配置Controller
 *
 * @author yajun_ren
 * @date 2022-08-30
 */
@RestController
@RequestMapping("/system/payConfig")
@Api(tags = "支付配置")
public class SysPayConfigController extends BaseController
{
    @Autowired
    private ISysPayConfigService sysPayConfigService;

    /**
     * 查询支付配置列表
     */
    @ApiOperation(value = "查询支付配置列表", notes = "查询支付配置列表")
    @PreAuthorize("@ss.hasPermi('system:payConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPayConfig sysPayConfig)
    {
        startPage();
        this.changeParameter(sysPayConfig.getParams());
        List<SysPayConfig> list = sysPayConfigService.selectSysPayConfigList(sysPayConfig);
        return getDataTable(list);
    }

    /**
     * 导出支付配置列表
     */
	@ApiOperation(value = "导出支付配置列表", notes = "导出支付配置列表")
    @PreAuthorize("@ss.hasPermi('system:payConfig:export')")
    @Log(title = "支付配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysPayConfig sysPayConfig)
    {
        List<SysPayConfig> list = sysPayConfigService.selectSysPayConfigList(sysPayConfig);
        ExcelUtil<SysPayConfig> util = new ExcelUtil<SysPayConfig>(SysPayConfig.class);
        return util.exportExcel(list, "支付配置数据");
    }

    /**
     * 获取支付配置详细信息
     */
	@ApiOperation(value = "获取支付配置详细信息", notes = "获取支付配置详细信息")
    @PreAuthorize("@ss.hasPermi('system:payConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sysPayConfigService.selectSysPayConfigById(id));
    }

    /**
     * 新增支付配置
     */
    @ApiOperation(value = "新增支付配置", notes = "新增支付配置")
    @PreAuthorize("@ss.hasPermi('system:payConfig:add')")
    @Log(title = "支付配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPayConfig sysPayConfig)
    {
        return toAjax(sysPayConfigService.insertSysPayConfig(sysPayConfig));
    }

    /**
     * 修改支付配置
     */
    @ApiOperation(value = "修改支付配置", notes = "修改支付配置")
    @PreAuthorize("@ss.hasPermi('system:payConfig:edit')")
    @Log(title = "支付配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPayConfig sysPayConfig)
    {
        return toAjax(sysPayConfigService.updateSysPayConfig(sysPayConfig));
    }

    /**
     * 删除支付配置
     */
    @ApiOperation(value = "删除支付配置", notes = "删除支付配置")
    @PreAuthorize("@ss.hasPermi('system:payConfig:remove')")
    @Log(title = "支付配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysPayConfigService.deleteSysPayConfigByIds(ids));
    }
}
